package dtaskboard.server.dao;

import java.util.List;

import dtaskboard.entities.Project;
import dtaskboard.entities.Sprint;

public class SprintDao extends GenericDao<Sprint> {

  @Override
  public Class<Sprint> getEntityClass() {
    return Sprint.class;
  }


  public Sprint getLastSprint(String projectName) {
    ProjectDao dao = new ProjectDao();
    Project p = dao.findByName(projectName);
    if (p.getSprints() == null || p.getSprints().size() == 0) {
      return null;
    }
    List<Sprint> sprints = p.getSprints();
    return sprints.get(sprints.size() - 1);
  }

}
